package com.example.servicelogin.config;


import com.example.servicelogin.exception.LoginCheckedInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//注册拦截器
@Configuration
public class WebConfig implements WebMvcConfigurer {
//    注册拦截方法
    @Autowired
    private LoginCheckedInterceptor loginCheckedInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        拦截所有资源
        registry.addInterceptor(loginCheckedInterceptor).addPathPatterns("/**");
    }
}
